//
//  RegestFirstStepViewController.m
//  DefendHealth
//
//  Created by 吾诺翰卓003 on 17/2/22.
//  Copyright © 2017年 iMacOne. All rights reserved.
//

#import "RegestFirstStepViewController.h"
#import "RegestSecondStepViewController.h"

@interface RegestFirstStepViewController ()
{
    UITextField * _phoneTF;
    UITextField * _codeTf;
    UIButton * _sendCode;
    
}
@end

@implementation RegestFirstStepViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.TitleNav.text = @"注册验证";
    self.leftbutton.hidden = YES;
    
    UIButton *addFriendsBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 23, 40, 40)];
//    [addFriendsBtn setTitle:@"" forState:UIControlStateNormal];
    [addFriendsBtn setImage:IMAGE(@"left-1") forState:UIControlStateNormal];
    [addFriendsBtn addTarget:self action:@selector(leftEvents) forControlEvents:UIControlEventTouchUpInside];
    addFriendsBtn.titleLabel.font = FONT(13);
    [addFriendsBtn setTitleColor:[ImageUtil colorWithRgb:0x333333] forState:0];
    [self.view addSubview:addFriendsBtn];
//    [self addView];
    self.view.backgroundColor = [UIColor whiteColor];
    [self initView];
}
-(void)initView{
    UITextField * phoneTf = [ReduceCode creatTextFieldWithFrame:CGRectMake(30, 92, kScreenWidth-60, 40) PlaceHold:@"请输入您的手机号码" PlaceHoldColor:UIColorFromRGB(0xb2b2b2) btnTitleFont:12 btnBackgroundColor:kClearColor KeyboardType:UIKeyboardTypeNumberPad isCorner:NO];
    phoneTf.leftView = [UIView new];
    [self.view addSubview:phoneTf];
    UIView * leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 74, 40)];
    leftView.backgroundColor = kClearColor;
    UIButton * areaBtn = [UIButton creatBtnWithFrame:CGRectMake(0, 0, 63, 40) btnTitle:@"+86" btnTitleColor:kBlackColor btnTitleFont:10 btnTagPrice:0 btnSetImage:IMAGE(@"trabge2") btnBackgroundColor:kClearColor isCorner:NO action:^(UIButton *button) {
        
    }];
    [areaBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
    [leftView addSubview:areaBtn];
//    [ToolUtil createLine:10 superView:leftView lift:kMaxX(areaBtn.frame) width:1 hight:20 color:UIColorFromRGB(0x888888)];
    phoneTf.leftView = leftView;
    phoneTf.leftViewMode = UITextFieldViewModeAlways;
    phoneTf.layer.borderColor = UIColorFromRGB(0xf2f2f2).CGColor;
    phoneTf.layer.borderWidth = 1;
    
    phoneTf.rightView = [UIView new];
    UIView * rightVIEW = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 40)];
    rightVIEW.backgroundColor = kClearColor;
    phoneTf.rightView = rightVIEW;
    phoneTf.rightViewMode = UITextFieldViewModeAlways;
    _phoneTF = phoneTf;
    

    
    
    UITextField * codeTf = [ReduceCode creatTextFieldWithFrame:CGRectMake(30, kMaxY(phoneTf.frame)+15, kScreenWidth-60, 40) PlaceHold:@"请输入验证码" PlaceHoldColor:UIColorFromRGB(0xb2b2b2) btnTitleFont:12 btnBackgroundColor:kClearColor KeyboardType:UIKeyboardTypeDefault isCorner:NO];
    
    
    
    codeTf.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 40)];
    codeTf.leftView.backgroundColor = kClearColor;
    codeTf.leftViewMode = UITextFieldViewModeAlways;
    
    codeTf.rightView = [UIView new];
    UIView * rightView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 62, 40)];
    rightView.backgroundColor = kClearColor;
    UIButton * sendCode = [ReduceCode creatBtnWithFrame:CGRectMake(0, 0, 62, 40) btnTitle:@"点击获取" btnTitleColor:UIColorFromRGB(0xe8602d) btnTitleFont:12 btnBackgroundColor:nil backgroundImage:nil isCorner:NO];    sendCode.selected = NO;
    
    [sendCode addTarget:self action:@selector(sendCode:) forControlEvents:UIControlEventTouchUpInside];
    [rightView addSubview:sendCode];
    codeTf.rightView = rightView;
    codeTf.rightViewMode = UITextFieldViewModeAlways;
    codeTf.layer.borderColor = UIColorFromRGB(0xf2f2f2).CGColor;
    codeTf.layer.borderWidth = 1;

    [self.view addSubview:codeTf];
    _codeTf = codeTf;
    _sendCode = sendCode;
    
    UITextField * passWtf = [ReduceCode creatTextFieldWithFrame:CGRectMake(30, kMaxY(codeTf.frame)+10, kScreenWidth-60, 40) PlaceHold:@"请输入密码 (6位以上)" PlaceHoldColor:UIColorFromRGB(0xb2b2b2) btnTitleFont:12 btnBackgroundColor:kClearColor KeyboardType:UIKeyboardTypeNumberPad isCorner:NO];
    passWtf.leftView = [UIView new];
    UIView * passwleftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 40)];
    passwleftView.backgroundColor = kClearColor;
    
    passWtf.leftView = passwleftView;
    passWtf.leftViewMode = UITextFieldViewModeAlways;
    passWtf.layer.borderColor = UIColorFromRGB(0xf2f2f2).CGColor;
    passWtf.layer.borderWidth = 1;
    
    passWtf.rightView = [UIView new];
    UIView * passwrightVIEW = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 40)];
    passwrightVIEW.backgroundColor = kClearColor;
    passWtf.rightView = passwrightVIEW;
    passWtf.rightViewMode = UITextFieldViewModeAlways;
    [self.view addSubview:passWtf];

    
    
    UITextField * nametf = [ReduceCode creatTextFieldWithFrame:CGRectMake(30, kMaxY(passWtf.frame)+5, kScreenWidth-60, 40) PlaceHold:@"请输入昵称 (3 - 10位)" PlaceHoldColor:UIColorFromRGB(0xb2b2b2) btnTitleFont:12 btnBackgroundColor:kClearColor KeyboardType:UIKeyboardTypeNumberPad isCorner:NO];
    nametf.leftView = [UIView new];
    UIView * nameleftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 40)];
    nameleftView.backgroundColor = kClearColor;

    nametf.leftView = nameleftView;
    nametf.leftViewMode = UITextFieldViewModeAlways;
    nametf.layer.borderColor = UIColorFromRGB(0xf2f2f2).CGColor;
    nametf.layer.borderWidth = 1;
    
    nametf.rightView = [UIView new];
    UIView * namerightVIEW = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 40)];
    namerightVIEW.backgroundColor = kClearColor;
    nametf.rightView = namerightVIEW;
    nametf.rightViewMode = UITextFieldViewModeAlways;
    [self.view addSubview:nametf];


    UIButton * registBtn = [ReduceCode creatBtnWithFrame:CGRectMake(30, kMaxY(nametf.frame)+20, kScreenWidth-60, 40) btnTitle:@"注 册" btnTitleColor:kWhiteColor btnTitleFont:14 btnBackgroundColor:UIColorFromRGB(0x888888) backgroundImage:nil isCorner:NO];
    registBtn.layer.cornerRadius = 2;
    [registBtn addTarget:self action:@selector(regist) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registBtn];
    
    CGFloat titleWidth = [ToolUtil autoWidth:@"我已同意《Y·RUN注册协议》" width:500 height:13 num:13];
    UIButton * protocolBtn = [ReduceCode creatBtnWithFrame:CGRectMake(0, kMaxY(registBtn.frame)+28, titleWidth, 13) btnTitle:@"我已同意《Y·RUN注册协议》" btnTitleColor:UIColorFromRGB(0xb2b2b2) btnTitleFont:13 btnBackgroundColor:kClearColor backgroundImage:nil isCorner:NO];
    protocolBtn.centerX = self.view.centerX;
    [protocolBtn addTarget:self action:@selector(goProtocolVC) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:protocolBtn];
    
}
-(void)regist{
    
}
-(void)goProtocolVC{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)sendCode:(UIButton *)sent{
    
}
-(void)addView{
    
    UIImageView * nameImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(10, 64+24, 27, 27) imageName:@"" isCorner:YES];
    nameImg.backgroundColor = [UIColor grayColor];
    [self.view addSubview:nameImg];
    
    
    UITextField * userName  = [ReduceCode creatTextFieldWithFrame:CGRectMake(kMaxX(nameImg.frame)+12, 0, kScreenWidth-kMaxX(nameImg.frame)*2-20, 16) PlaceHold:@"请输入常用手机号" PlaceHoldColor:UIColorFromRGB(0x999999) btnTitleFont:16 btnBackgroundColor:nil KeyboardType:UIKeyboardTypeDefault isCorner:NO];
    userName.centerY = nameImg.centerY;
    [self.view addSubview:userName];
    
    
    
    
    
    UIView * loginLin  = [[UIView alloc]initWithFrame:CGRectMake(10, kMaxY(nameImg.frame)+17, kScreenWidth-20, 1)];
    loginLin.backgroundColor = UIColorFromRGB(0xbcbcbc);
//    loginLin.centerX = loginImg.centerX;
    [self.view addSubview:loginLin];
    
    
    
    
    UIImageView * passImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(10, kMaxY(nameImg.frame)+34, 27, 27) imageName:@"" isCorner:YES];
    passImg.backgroundColor = [UIColor grayColor];
    
    [self.view addSubview:passImg];
    
    UITextField * userPass  = [ReduceCode creatTextFieldWithFrame:CGRectMake(kMaxX(passImg.frame)+12, 0, kScreenWidth-kMaxX(nameImg.frame)*2-20, 16) PlaceHold:@"请输入验证码" PlaceHoldColor:UIColorFromRGB(0x999999) btnTitleFont:16 btnBackgroundColor:nil KeyboardType:UIKeyboardTypeDefault isCorner:NO];
    userPass.centerY = passImg.centerY;
    [self.view addSubview:userPass];
    
    UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(WindowWidth-10-90, kMaxY(nameImg.frame)+34, 90, 30)];
    [btn1 setTitle:@"获取验证码" forState:UIControlStateNormal];
    [btn1 addTarget:self action:@selector(getCode) forControlEvents:UIControlEventTouchUpInside];
    btn1.titleLabel.font = FONT(13);
    btn1.layer.cornerRadius = 14;
    btn1.layer.masksToBounds = YES;
    btn1.backgroundColor = [ImageUtil colorWithRgb:0x7b7c7c];
    [btn1 setTitleColor:[ImageUtil colorWithRgb:0xffffff] forState:0];
   
    [self.view addSubview:btn1];
    
    UIButton * loginBtn = [UIButton creatBtnWithFrame:CGRectMake(50, kMaxY(passImg.frame)+50, kScreenWidth-100, 40) btnTitle:@"下一步" btnTitleColor:kWhiteColor btnTitleFont:18 btnTagPrice:0 btnSetImage:nil btnBackgroundColor:UIColorFromRGB(0x7b7c7c) isCorner:YES action:^(UIButton *button) {
        RegestSecondStepViewController *stVC = [RegestSecondStepViewController new];
        stVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:stVC animated:YES];
        
    }];
    loginBtn.layer.cornerRadius = 20;
    
    [self.view addSubview:loginBtn];
}

-(void)getCode{
    
}
@end
